<script>
    layui.use(['admin', 'form', 'user'], function () {
        var $ = layui.$
            , setter = layui.setter
            , admin = layui.admin
            , router = layui.router()
            , search = router.search;

        var userId = layui.router().search.userId;
        var token = layui.router().search.token;

        //请求登入接口
        admin.req({
            url: layui.setter.baseUrl + '/auth/mgr_auth'
            , data: {
                userId: userId,
                token: token
            }, done: function (res) {
                layui.data(setter.tableName, {
                    key: setter.request.tokenName
                    , value: res.data.access_token
                });

                layer.msg('登入成功', {
                    offset: '15px'
                    , icon: 1
                    , time: 1000
                }, function () {
                    location.hash = search.redirect ? decodeURIComponent(search.redirect) : '/';
                });
            }
        });
    });
</script>